<?php

class ControllerWpFeedback extends Controller
{
    private $error = array();

    public  function getList(){
        $this->load->model('wp/feedback');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_feedback->getList(  $this->customer->getId());


        foreach ($data as &$item){
            $item['mine'] = $item['user_id'] == $this->customer->getId();
        }

        $this->model_wp_feedback->setFeedbackRead($this->customer->getId());

        $this->response->setOK( $data);
    }


    public function unReadCount()
    {
        $this->load->model('wp/feedback');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_feedback->unReadCount($this->customer->getId());
        $this->response->setOK( $data);

    }



    public function setFeedbackRead(){
        $this->load->model('wp/feedback');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_feedback->setFeedbackRead($this->customer->getId());
        $this->response->setOK( $data);
    }

    public function feedback()
    {
        $this->load->model('wp/feedback');
        if (! $this->actionCheck(true, true)) {
            return;
        }


        $this->model_wp_feedback->feedback($this->request->post['message'],
            $this->customer->getId(),$this->customer->getFirstName());
        $this->response->setOK( );

    }
}